import 'package:flutter/material.dart';
import '../pages/Tabs.dart';
import '../pages/Form.dart';
import '../pages/search.dart';
import '../pages/Product.dart';
import '../pages/ProductInfo.dart';

import '../pages/user/Login.dart';
import '../pages/user/RegisterFirst.dart';
import '../pages/user/RegisterSecond.dart';
import '../pages/user/RegisterThird.dart';

import '../pages/AppBarDemo.dart';
import '../pages/AppBarDemoSecond.dart';
import '../pages/TabBarController.dart';
import '../pages/User.dart';
import '../pages/Button.dart';
import '../pages/TextField.dart';
import '../pages/CheckBox.dart';
import '../pages/Radio.dart';
import '../pages/FormSecond.dart';
import '../pages/DatePicker.dart';
import '../pages/DatePickerPub.dart';
import '../pages/Swiper.dart';
import '../pages/Dialog.dart';
import '../pages/MyDialog.dart';
import '../pages/Data.dart';
import '../pages/Http.dart';
import '../pages/Dio.dart';


// 配置路由
final routes = { 
      // 03 全局定义，使用命名路由
      '/':(context)=>Tabs(),
      '/form':(context)=>FormPage(),
      '/product':(context)=>ProductPage(),
      '/productInfo':(context,{arguments})=>ProductInfoPage(arguments:arguments),
      '/search':(context,{arguments})=>SearchPage(arguments:arguments), // 名称只能是 arguments
      '/login':(context)=>LoginPage(),
      '/registerFirst':(context)=>RegisterFirstPage(),
      '/registerSecond':(context)=>RegisterSecondPage(),
      '/registerThird':(context)=>RegisterThirdPage(),
      '/appBarDemo':(context)=>AppBarDemoPage(),
      '/appBarDemoSecond':(context)=>AppBarDemoSecondPage(),
      '/tabBarController':(context)=>TabBarControllerPage(),
      '/user':(context)=>UserPage(),
      '/button':(context)=>ButtonPage(),
      '/textField':(context)=>TextFieldPage(),
      '/checkBox':(context)=>CheckBoxPage(),
      '/radio':(context)=>RadioPage(),
      '/formSecond':(context)=>FormSecondPage(),
      '/datePicker':(context)=>DatePickerPage(),
      '/datePickerPub':(context)=>DatePickerPubPage(),
      '/swiper':(context)=>SwiperPage(),
      '/dialog':(context)=>DialogPage(),
      '/myDialog':(context)=>MyDialogPage(),
      '/data':(context)=>DataPage(),
      '/http':(context)=>HttpPage(),
      '/dio':(context)=>DioPage(),

};

// 03
//固定写法
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
      MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};